package j04liu;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Stream;

public class J1 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,12,45,78,66,23);
        System.out.println("list = " + list);
        //60分以下
//        Stream<Integer> s1 = list.stream();
//        Stream<Integer> s2 = s1.filter(num->{
////            System.out.println("num = " + num);
//            //true 数据留下
//            //false 数据不要
////            return true;
//            return num<60;
//        });
//        s2.forEach(num-> {
//            System.out.println(num);
//        });
//        list.stream().filter(num->num<60).forEach(num-> System.out.println(num));
//        list.stream().filter(num->num>=60).forEach(num-> System.out.println(num));

    }
}

class J2{
    public static void main(String[] args) {
        //.
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"马云", "马化腾", "李彦宏", "王兴", "马致远", "俞敏洪", "张朝阳", "马超");
        //马开头
//        list.stream().filter(el->el.startsWith("马")).forEach(el-> System.out.println(el));
        //2
        list.stream()
                .filter(el->el.startsWith("马"))
                .filter(el->el.length()==2)
                .forEach(el-> System.out.println(el));
    }
}

class J3{
    public static void main(String[] args) {
        String[] arr = {"abc","ddd","tttttt","yy","a"};
        Stream<String> s1 = Arrays.stream(arr);

        Stream<Integer> s2 = Stream.of(12,44,55,12,44);
//        s2.limit(2).forEach(el-> System.out.println(el));
        s2.distinct().forEach(el-> System.out.println(el));

    }
}